<layout name='layout_page' />

<div class="row">
	<div class="col-lg-12">
		<div class="row">
			<div class="col-lg-12">
				<ol class="breadcrumb">
					<li><a href="<{:U('Index/index')}>">Home</a></li>
					<li>Mentees</li>
					<li class="active"><span>Reset password</span></li>
				</ol>
				<h1>Reset password</h1>
			</div>
		</div>

		<div class="row">
			<div class="col-lg-12">
				<div class="main-box clearfix" style="padding: 20px 0;">
					<form id="ajaxForm" action="<{:U('Profile/setpsd')}>" method="post" class="form-horizontal form-validata col-lg-4" style="margin: 0 30px;">
					  	<div class="form-group">
							<label>Old password</label>
							<input type="password" class="form-control" id="oldpassword" name="oldpassword" value="" placeholder="Enter your old password" data-rule-required="true">
						</div>
						<div class="form-group">
							<label>New password</label>
							<input type="password" class="form-control" id="password" name="password" value="" placeholder="Enter your new password" data-rule-required="true" data-rule-pwd="true">
						</div>
						<div class="form-group">
							<label>Confirm password</label>
							<input type="password" class="form-control" id="repassword" name="repassword" value="" placeholder="Repeat enter new password" data-rule-required="true" data-rule-equalto="#password">
						</div>
					  	<div class="form-group">
							<div class="col-md-9 col-sm-offset-2">
								<button type="submit" id="myBtn" class="btn btn-success"><{:L('_submit')}></button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	//validation验证
	$("form.form-validata").validate({
		errorElement: "span",
        errorClass: "help-block",
        errorPlacement: function(error, element) {
        	if(element.attr("type")=="radio"){
        		element.parent().parent().addClass("has-error").append(error);
        	}else{
        		element.parent().addClass("has-error").append(error);	
        	}
		},
		success:function(element){
			if(element.attr("type")=="radio"){
        		element.parent().parent().removeClass("has-error");
        	}else{
        		element.parent().removeClass("has-error");
        	}
	        
	    }
		
	})

	$.validator.addMethod("pwd",function(value,element){
        return this.optional(element) || testPass(value);
    },"Password must be at least 8 characters and include at least 3 of the following requirement<br/>Contain at least 1 English uppercase chatacters (A-Z)<br/>Contain at least 1 English lowercase characters (a-z)<br/>Contain at least 1 numeric base 10 digits (0-9)<br/>Contain at least 1 non-alphanumeric characters (for example: ?,!,&,%)");


	var btnStr = $("#myBtn").html();
	$('#ajaxForm').ajaxForm({
		beforeSubmit:function(){
			validata = $("form.form-validata").valid();
			 if (validata){
			 	$("#myBtn").attr('disabled','disabled').html('<i class="fa fa-spinner fa-spin"></i> waiting...');
			 }
			 return validata;
		},
		success:function(responseText, statusText){
			$("#myBtn").removeAttr('disabled').html(btnStr);
			if (statusText == 'success') {
				var responseText=eval('('+responseText+')');
				var url=responseText.url;
				if(responseText.state == 'SUCCESS'){
					_alert2("SUCCESS",responseText.message,url);
				}else{
					_alert2("ERROR",responseText.state,url);
				}			
			}
		}
	})
});
</script>